<?php
/**
 * Created by PhpStorm.
 * User: 共赢岛
 * Date: 2023/12/2
 * Time: 16:36
 */

namespace App\Http\Resources;

use App\Admin\Services\CarService;
use App\Services\LifeCycle\OrderService;
use Illuminate\Http\Resources\Json\JsonResource;

class PackageOrderResource extends  JsonResource
{
    public function toArray($request)
    {
        return [
            'order_id' => $this->id,
            'order_sn' => $this->order_sn,
            'order_status' => $this->status,
            'order_status_title' => OrderService::orderStatusTitle($this->status),
            'brand_pic' => path2url($this->brand->pic),
            'package_title' => $this->package_title,
            'package_category_title' => $this->package->type == PACKAGE_TYPE_SALE ? $this->category->title : '售后'.$this->category->title,
            'package_cars' => CarService::carJsonSwitch($this->category->car_ids),
            'price' => $this->price,
            'original_price' => $this->package->original_price,
            'created_at' => $this->created_at ? $this->created_at->format('Y-m-d H:i:s') : '',
        ];
    }
}